#include "../include/someip_service.hpp"

using namespace someip_app;

#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
someip_service *someip_srv_ptr(nullptr);

void handle_signal(int _signal) {
    if (someip_srv_ptr != nullptr &&
            (_signal == SIGINT || _signal == SIGTERM))
        someip_srv_ptr->terminate();
}
#endif


int main(int argc, char **argv)
{
    someip_service someip_srv;


#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
    someip_srv_ptr = &someip_srv;
    signal(SIGINT, handle_signal);
    signal(SIGTERM, handle_signal);
#endif


    if (someip_srv.init()) {
        someip_srv.start();
        return 0;
    } else {
        return 1;
    }
}
